<template>
  <div class="top">
    <!-- <input style="float:left;" @click="setMenuCode" value="传值" type="button"> -->
    <a class="logo" :href="href">{{unitName}}智慧教育云平台 </a>
    <!-- <nav>
      <router-link :to="{path:'/indexNotice/inbox'}">收到的通知</router-link>
      <router-link v-show="flag" :to="{path:'/indexNotice/outbox'}">发通知</router-link>
    </nav> -->
   
    <div class="user">
       <el-tooltip class="item" effect="dark" :content="userName" placement="bottom"><span class="changenewname">{{userName|newUserName}}</span></el-tooltip>
       <el-tooltip class="item" effect="dark" content="在线帮助" placement="bottom">
         <a :href="help" target="_blank"><i class="el-icon-question"></i></a>
        </el-tooltip>
        <!-- <el-tooltip class="item" effect="dark" content="版本说明" placement="bottom">
         <a :href="version" target="_blank"><i class="el-icon-info"></i></a>
        </el-tooltip> -->
        <el-tooltip class="item" effect="dark" content="退出登录" placement="bottom">
         <a  href="javascript:;" @click="layout"><i class="el-icon-circle-close"></i></a>
        </el-tooltip>
      <!-- <ul class="ul02">
        <li class="on">
          <a :href="help" target="_blank">在线帮助</a>
        </li>
        <li>
          <a :href="version" target="_blank">版本说明</a>
        </li>
        <li>
          <a href="javascript:;" @click="layout">
            <i class="icon iconfont iconguanji"></i>注销
          </a>
        </li>
      </ul> -->
    </div>
  </div>
</template>

<script>
export default {
  name: "top",
  data() {
    return {
      userName: "张扬",
      flag:true,
      href: "",
      unitName: "",
      version: "",
      help: ""
    };
  },
  filters:{
    newUserName:function(mes){
      if(mes){
        let nr = mes.toString();
        nr = nr.substring(0,1);
        return nr
      }else{
        return mes
      }
    }
  },
  mounted() {
    this.getMulu();
    this.getUser();
    this.getVandH();
    this.setMenuCode(this.flag);
    // this.setMenuCode(true);
  },
  methods: {
    getMulu(){
      let url = "/base/query/menu/auth";
      this.$ajax.post(url).then(out => {
          this.hw_result(out.data, true, this, () => {
            this.flag = out.data.result;
            
          });
        })
        .catch(error => {});
    },
    getUser() {
      var url = "/api/login/user";
      this.$ajax.post(url).then(out => {
          this.hw_result(out.data, true, this, () => {
            console.log(out.data);
            this.userName = out.data.result.userName;
            this.href = out.data.result.indexUrl;
            this.unitName = out.data.result.unitName;
            this.version = out.data.result.moduleUrl + "version";
          });
        })
        .catch(error => {});
    },
    getVandH() {
      var url = "/get/online_help";
      this.$ajax.get(url).then(out => {
          this.hw_result(out.data, true, this, () => {
            this.help = out.data.result;
            console.log(this.help)
          });
        })
        .catch(error => {});
    },
    layout() {
      this.hw_confirm("您确定注销登录吗？", () => {
        let url = "/api/login/out";
        this.$ajax
          .post(url)
          .then(out => {
            this.hw_result(out.data, true, this, () => {
              window.close();
            });
          })
          .catch(error => {});
      });
    },
    // 传输目录参数（发件箱显示不显示）
    setMenuCode(v){
      this.$emit("menuCode",v);
    }

  }
};
</script>

<style>
</style>
